/**
 * @author : cyb1010
 * @date   : 2024-06-04 09:08:22
 * @file   : bird.cpp
 */
#include <bits/stdc++.h>
using namespace std;
#define fo(s) freopen(s ".in", "r", stdin), freopen(s ".out", "w", stdout)
#define fi first
#define se second
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef priority_queue<pair<int, bool>> Q;
const int N = 100010;
int __, n;
vector<int> g[N];
Q q[N];
void merge(Q &x, Q &y) {
    if (x.size() < y.size()) x.swap(y);
    while (!y.empty()) x.push(y.top()), y.pop();
}
void dfs(int p, int fa) {
    for (int i : g[p])
        if (i != fa) dfs(i, p), merge(q[p], q[i]);
    if (q[p].empty()) {
        q[p].emplace(1, 0);
    } else if (q[p].size() == 1) {
        auto x = q[p].top();
        q[p].pop();
        if (x.se)
            x.se = 0, x.fi += 2;
        else
            x.se = 1;
        q[p].push(x);
    } else {
        auto x = q[p].top();
        q[p].pop();
        auto y = q[p].top();
        q[p].pop();
        q[p].emplace(x.fi + y.fi + 1, x.se | y.se);
        if (x.se && y.se) q[p].emplace(1, 0);
    }
}
int main() {
    fo("bird");
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for (int i = 1, x, y; i < n; i++)
        cin >> x >> y, g[x].push_back(y), g[y].push_back(x);
    dfs(1, 0);
    cout << q[1].top().fi + q[1].top().se << '\n';
    return 0 ^ __ ^ 0;
}